TARGET = wapiwrap.dll
SRCS = widget.c callback.c delegate.c graph.c dialog.c button.c
INCS = widget.h callback.h delegate.h graph.h dialog.h button.h
TARGETLIB = $(TARGET:.dll=.a)
OBJS = $(SRCS:.c=.o)
CFLAGS = -Wall -D BUILD_DLL
LFLAGS = -s -l gdi32
CC = gcc

# link the projects if all its objects is up to date
$(TARGET) : $(OBJS)
	$(CC) $(OBJS) -shared -o $(TARGET) $(LFLAGS) -Wl,--out-implib,wapiwrap.a

# compile object if it do not exist or if its been updated
.c.o :
	$(CC) $(CFLAGS) -c $<

# recompile all objects if a include file have been updated
$(OBJS): $(INCS)

# create the unit test program
test: unittest.c $(TARGET)
	gcc -Wall unittest.c $(TARGET) -o test.exe

# clean the project from .exe and .o files
clean:
	del $(TARGETLIB) $(TARGET) $(OBJS)

